package com.myhome.money.rabbitmq.moneyrabbitmq.controller;

import com.myhome.money.rabbitmq.moneyrabbitmq.callback.CallBackSender;
import com.myhome.money.rabbitmq.moneyrabbitmq.fanout.FanoutSender;
import com.myhome.money.rabbitmq.moneyrabbitmq.hello.HelloSender1;
import com.myhome.money.rabbitmq.moneyrabbitmq.hello.HelloSender2;
import com.myhome.money.rabbitmq.moneyrabbitmq.hello.UserSender;
import com.myhome.money.rabbitmq.moneyrabbitmq.topic.TopicSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 许路路
 */
@RestController
@RequestMapping("/rabbit")
public class HomeController {

    @Autowired
    private HelloSender1 helloSender1;

    @Autowired
    private HelloSender2 helloSender2;

    @Autowired
    private UserSender userSender;

    @Autowired
    private TopicSender topicSender;

    @Autowired
    private FanoutSender fanoutSender;

    @Autowired
    private CallBackSender callBackSender;

    @GetMapping("/hello")
    public void hello() {
        for (int i = 0; i < 10; i++) {
            helloSender1.send();
            helloSender2.send("这个是222");
        }
    }

    @GetMapping("/user")
    public void user() {
        for (int i = 0; i < 10; i++) {
            userSender.send();
        }
    }

    @GetMapping("/topic")
    public void topic() {
        for (int i = 0; i < 10; i++) {
            topicSender.send();
        }
    }

    @GetMapping("/fanout")
    public void fanout() {
        fanoutSender.send();
    }

    @GetMapping("/callback")
    public void callbak() {
        callBackSender.send();
    }

}
